class Solution:
    def lemonadeChange(self, bills):
        """
        :type bills: List[int]
        :rtype: bool
        """
        if len(bills) == 0:
            return True
        money = []
        for bill in bills:
            if bill == 5:
                money.append(5)
            elif bill == 10:
                if 5 in money:
                    money.remove(5)
                    money.append(10)
                else:
                    return False
            elif bill == 20:
                if 10 in money:
                    if 5 in money:
                        money.remove(5)
                        money.remove(10)
                        money.append(20)
                    else:
                        return False
                elif money.count(5) >= 3:
                    money.append(20)
                    money.remove(5)
                    money.remove(5)
                    money.remove(5)
                    continue
                else:
                    return False
        return True
        
        
def main():
    sol = Solution()
    print(sol.lemonadeChange([5,5,10,10,20]))
    
if __name__=="__main__":
    main()